// pages/print/preview/preview.js
const utils = require("../../../utils/utils");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        src: '',
        left: '227.5',
        num: 1,
        name:'',
        previewSrc:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        that.setData({
            code: options.code||'',
            name:options.name,
            tagFloor:options.tagFloor,
            serviceMainId:options.serviceMainId,
            serviceSubtypeId:options.serviceSubtypeId||'',
            clothesId:options.clothesId||'',
            certificatesPhoto:options.certificatesPhoto||'',
        })
        wx.getSystemInfo({
            success: (result) => {
                var model = result.model;
                if (model == 'iPhone X') {
                    that.setData({
                        pdbottom: '68rpx',
                        src: options.imgsrc
                    })
                } else {
                    that.setData({
                        pdbottom: '40rpx',
                        src: options.imgsrc
                    })
                }
            },
        })
    },
    btnConfirm() {
        var that = this;
        if(!utils.is_define(this.data.src)){
          utils.toast('证件处理失败,请返回重新上传');
          return false;
        }
        console.log(that.data.name)
        wx.redirectTo({
            url: '../list/list?code=' + that.data.code + '&name=' + that.data.name + '&path=' + that.data.src + '&pageNum=1&fileUrl='+that.data.src+'&serviceMainId='+that.data.serviceMainId+'&serviceSubtypeId='+that.data.serviceSubtypeId+'&tagFloor='+that.data.tagFloor+'&clothesId='+that.data.clothesId+'&certificatesPhoto='+that.data.certificatesPhoto
          })
      },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    }
})